package 链表;

/**
 * @author 陈艺博
 * @date 2021-02-18 10:12
 * @description https://leetcode-cn.com/problems/middle-of-the-linked-list/
 **/
public class _876_middle_of_the_linked_list_链表的中间结点 {
    // #快慢指针思想
    public ListNode middleNode(ListNode head) {
        //慢指针
        ListNode slow = head;
        //快指针
        ListNode fast = head;
        while (fast != null && fast.next != null) {
            slow = slow.next;
            fast = fast.next.next;
        }
        return slow;
    }
}
